Những câu hỏi liên quan
NgocTuan
Xem chi tiết
Lê Chiêu Nguyên	Vũ
4 tháng 4 2023 lúc 10:11

program Min;
uses crt;
var i,n:integer;
begin
   clrscr;
   write('Nhap n: '); readln(n);
   write('Cac so le nho hon hoac bang ',n,'la :');
   for i:=1 to n do if i mod 2 = 1 then write(i:4);
   readln
end.

Bình luận (0)
trần hoàng
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 4 2022 lúc 21:53

#include <bits/stdc++.h>

using namespace std;

long long i,n,kt,j;

int main()

{

cin>>n;

for (i=2; i<=n; i++)

{

kt=0;

for (j=2; j*j<=i; j++)

if (i%j==0) kt=1;

if (kt==0) cout<<i<<" ";

}

return 0;

}

Bình luận (0)
Gà Công Nghệ
Xem chi tiết
Anh Phạm
28 tháng 8 2021 lúc 19:43

uses crt;

var n,i,o,d:integer;

function ktnt(n:integer): integer;

var i,d:integer;

begin

d:=0;

for i:=1 to sqrt(n) do

if (n mod i=0) then d:=d+1;

if d=2 then ktnt=0

else ktnt=1;

end;

begin

readln(n);

writeln(' so nguyen to be hon hoac bang n la'); {a}

for i:=1 to n do

if ktnt(i)=0 then writeln(i);

writeln('so nguyen to nho nhat khong be hon n');

o:=n;

while o>0 do

begin

if ktnt(o)=0 then

begin

write(o);

break;

end;

o:=o+1;

end;

writeln('cặp số nguyên tố là hai số nguyên lẻ liên tiếp nhỏ hơn hoặc bằng n');

o:=0;

o:=1;

d:=0;

for i:=o+2 to n do

begin

if ktnt(i)=0 then

begin

d:=d+1;

write(i,' ');

if d<2 then continue;

end;

d:=0;

writeln;

end;

readln;

end.

Bình luận (1)
Bé Kunz
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 3 2021 lúc 22:24

Bài 1: 

uses crt;

var a:array[1..200]of integer;

i,n,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

begin

write('A[',i,']='); readln(a[i]);

end;

t:=0;

for i:=1 to n do 

  if a[i] mod 5=0 then t:=t+a[i];

writeln('Tong cac so chia het cho 5 la: ',t);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
21 tháng 3 2021 lúc 22:25

Bài 2: 

uses crt;

var st:string;

d,i:integer;

begin

clrscr;

write('Nhap xau:'); readln(st);

d:=length(st);

for i:=1 to d do 

  if st[i]=#32 then delete(st,i,1);

writeln(st);

readln;

end.

Bình luận (0)
scar titan
28 tháng 7 2021 lúc 10:11

python có ko bạn

 

Bình luận (0)
Ngọc Ty
Xem chi tiết
Kiều Vũ Linh
24 tháng 4 2023 lúc 18:56

Var a:array[1..100] of integer;

i,n:integer;

s:longint;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap phan tu thu ',i,' = ');readln(a[i]);

s:=s+a[i];

End;

Write('Cac phan tu vua nhap la ');

For i:=1 to n do

Write(a[i]:8);

Writeln;

Write('Tong cua chung la ',s);

Readln

End.

Bình luận (0)
Quỳnh
Xem chi tiết
Minh Lệ
29 tháng 4 2021 lúc 14:33

Program HOC24;

var a: array[1..32000] of integer;

i,n,d: integer;

begin

write('Nhap N: ');

for i:=1 to n do

begin

write('A[',i,']='); readln(a[i]);

end;

write('Day vua nhap la: '); 

for i:=1 to n do write(a[i],' '); writeln;

d:=0;

for i:=1 to n do if a[i]>0 then d:=d+1;

write('Co ',d,' so duong');

readln

end.

Bình luận (0)
Oanh Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 12 2020 lúc 21:00

uses crt;

var a:array[1..200]of integer;

i,n,tbc,dem:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

       write('A[',i,']='); readln(a[i]);

  end;

writeln('Cac so duong chan la: ');

for i:=1 to n do 

  if (a[i] mod 2=0) and (a[i]>0) then write(a[i]:4);

writeln;

tbc:=0;

dem:=0;

for i:=1 to n do 

  if (-1000<=a[i]) and (a[i]<=1000) then

begin

tbc:=tbc+a[i];

dem:=dem+1;

end;

writeln('Trung binh cong cac phan tu co gia tri trong pham vi tu -1000 den 1000 la: ',tbc/dem:4:2);

readln;

end.

Bình luận (0)
Phạm Thị Đông Nhi_HDI
Xem chi tiết
shitbo
21 tháng 6 2020 lúc 16:54

program hello;

uses crt;

Var n,i,j,k: integer;

a: array[1..50] of integer;

begin;

a[1]:=k;

Readln(n);

For i:=1 to n do

Begin;

Writeln('nhap a[',i,'] '); Readln(a[i]);

End;

For i:=1 to n-1 do

For j:=i+1 to n do

If a[i]<a[j] then k:=a[j];

Writeln('gia tri lon nhat la', k);

end.

Bình luận (0)
 Khách vãng lai đã xóa
KenShi
Xem chi tiết
Nguyễn Lê Phước Thịnh
18 tháng 12 2021 lúc 0:39

Bài 2: 

#include <bits/stdc++.h>

using namespace std;

long long x,y;

int main()

{

cin >>x>>y;

cout<<x<<" "<<y;

swap(x,y);

cout<<x<<" "<<y;

return 0;

}

Bình luận (0)